Node2D plugin example
This example shows how to create a custom 2D node VideoView2D in a Kanzi Engine plugin. The VideoView2D node renders video files whose resolution is divisible by 2 and are encoded with the MPEG-4 codec. The VideoView2D node does not play the audio track in video files.
You can find the video file in the Application/bin directory.
The example shows how to use the Kanzi Engine plugins. For Android, a shared image texture utilizing OES_EGL_image_external extension is used for streaming the video from an external context.
You can find the example in the <KanziWorkspace>/Examples/Node2D_plugin directory.
To learn how to create a Kanzi Engine plugin, see Creating Kanzi Engine plugins.
The example runs on Windows and Android platforms:
- Windows platform uses Microsoft Media Foundation for video playback. You can find the source files for the Windows platform in <KanziWorkspace>/Examples/Node2D_plugin/Application/src/platform_specific/win32/src.NOTE
To run the Node2D plugin example on Windows 10 N and Windows 10 KN versions, you must install the Media feature pack provided by Microsoft.
- Android platform uses the native media player. You can find the source files for the Android platform in <KanziWorkspace>/Examples/Node2D_plugin/Application/src/platform_specific/android/src.
- You can find the code common to both platforms in <KanziWorkspace>/Examples/Node2D_plugin/Application/src/plugin.
Using the external texture handle
Because Android’s native code and Kanzi application framework run in different context, they cannot share the GPU resources. A widely available OpenGL extension (GL_TEXTURE_EXTERNAL_OES) provides the support for external texture resources that can be shared between contexts with few limitations. The Node2D_plugin example uses the Android media player to render a video stream to a surface view that is bound to the external texture handle. On the Kanzi side, the texture of the node that renders the video is bound to the same external texture handle, and displayed in the render loop.
You can use this approach on other platforms where:
- The device supports the GL_TEXTURE_EXTERNAL_OES extension.
- A service in another context is capable of providing a texture bound to an external texture handle.
A typical example is a streaming video.